package com.acorn.community.web.controller.user;

import com.acorn.community.client.req.AccessUserReq;
import com.acorn.community.client.req.GetUserAccountByUserIdReq;
import com.acorn.community.client.resp.GetUserAccountByUserIdResp;
import com.acorn.community.common.annotation.access.AccessUser;
import com.acorn.community.common.api.Resp;
import com.acorn.community.service.user.UserAccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSupport;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 用户账户
 *
 * @author tianshiwei
 */
@RestController
@RequestMapping("/account/")
@Api(value = "用户账户接口", tags = "1. 用户账户接口")
public class UserAccountController {

    @Resource
    private UserAccountService userAccountService;

    /**
     * 通过用户id获取用户账户信息
     *
     * @param getUserAccountByUserId
     * @return
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "1.查询用户账户信息", notes = "查询用户账户信息")
    @RequestMapping("getUserAccountByUserId")
    public Resp<GetUserAccountByUserIdResp> getUserAccountByUserId(@RequestBody GetUserAccountByUserIdReq getUserAccountByUserId, @AccessUser AccessUserReq accessUserReq) {
        getUserAccountByUserId.setAccessUser(accessUserReq);
        GetUserAccountByUserIdResp result = userAccountService.getUserAccountByUserId(getUserAccountByUserId);
        return Resp.success(result);
    }
}
